package com.dingreading.cloud.soms.service;

import com.dingreading.cloud.common.util.PageUtil;
import com.dingreading.cloud.soms.dto.CaScheduleLessonDto;
import com.dingreading.cloud.soms.dto.CallMemberDto;
import com.dingreading.cloud.soms.entity.CaScheduleLesson;
import com.mybatisflex.core.paginate.Page;
import com.mybatisflex.core.service.IService;

import java.util.Date;
import java.util.List;

/**
 * 服务层。
 *
 * @author Administrator
 * @since 2023-11-22
 */
public interface CaScheduleLessonService extends IService<CaScheduleLesson> {

    Page<CaScheduleLessonDto> pageListV3(
            PageUtil pageUtil, String corpUid, String storeUid, String keyword, Integer status, String scheduleUid, String lessonUid,
            Long classId, String className, Long roomId, String username, String projectUid, String beginDate, String endDate
    );

    List<CaScheduleLessonDto> calendarListV3(String corpUid, String storeUid, String keyword, Integer status,
                                             Long classId, Long roomId, String username, String projectUid,
                                             String beginDate, String endDate);

    List<CaScheduleLesson> getByStoreUid(String storeUid, String keyword, Integer status);

    long dropBean(String storeUid, String lessonUid);

    void dropByScheduleUid(String storeUid, String scheduleUid);

    // 查询冲突的活动-社团
    List<CaScheduleLesson> queryConflictLessonToClass(String corpUid, String storeUid, List<String> teachDates, String beginTime,
                                                      String endTime, Long classId);

    List<CaScheduleLesson> queryConflictLessonToRooms(String corpUid, String storeUid, List<String> teachDates, String beginTime,
                                                      String endTime, List<Long> roomIds, String scheduleUid, String lessonUid);

    List<CaScheduleLesson> queryConflictLessonToTeachers(String corpUid, String storeUid, List<String> teachDates, String beginTime,
                                                         String endTime, List<String> usernames, String scheduleUid, String lessonUid);

    // 更新未进行活动的活动信息
    void updateLessons(
            String corpUid, String storeUid, String scheduleUid,
            Long roomId, String roomUid, String roomName, String content, String usernames, String teacherUid, String teacherName,
            String uid, String fullName, String remark
    );

    CaScheduleLesson getLessonInfo(String storeUid, String lessonUid);

    CaScheduleLessonDto getLessonDto(String storeUid, String lessonUid);

    List<CaScheduleLessonDto> getLessonByUids(String storeUid, List<String> uids);

    boolean haveClassId(String storeUid, Long classId, List<Integer> status);

    boolean haveClassroom(String storeUid, Long classroomId, List<Integer> status);

    // 点名，更新会员们的参与状态对应的数量
    boolean callNames(
            String storeUid, String lessonUid, String teacherName,
            int reachNum, int lateNum, int askLeaveNum, int notReachNum, int noHourNum,
            Integer lessonStatus, String staffUid, String staffName, Date callTime
    );

    // 更新活动关联社团的会员数量
    void updateStudentNum(String storeUid, Long classId, int stuNum);

    // 更新插班、补缺、试听的会员数量
    void updateStudentTempNum(String storeUid, String lessonUid, int stuNum);

    // 获取可补缺的活动
    Page<CaScheduleLessonDto> getMakeUpLessonsV2(
            PageUtil pageUtil, String storeUid, String lessonUid, String projectUid, String stageUid, Long classId,
            Long roomId, String username, String beginDate, String endDate
    );

    // 活动状态设置为已结束
    boolean setOk(String storeUid, String lessonUid, String staffUid, String staffName, Date closeTime);


    // 当天未活动设置为已取消
    // 在定时器下加上注解，防止报错
    void setCancel(String corpUid, String lessonUid, String staffUid, String staffName);

    // 查询已完成活动的点名详情-分页
    Page<CaScheduleLessonDto> getOkLessonDtoPageV3(
            PageUtil pageUtil, String corpUid, String storeUid, String className, String projectUid,
            String stageUid, Long roomId, String teacherUid, String beginDate, String endDate,
            int staffRole, String username
    );

    // 查询已完成活动的点名详情
    List<CaScheduleLesson> getOkLessonsV3(
            String storeUid, String className, String projectUid,
            String stageUid, Long roomId, String teacherUid, String beginDate, String endDate, String keyword
    );

    // 获取点名时的会员详情，社团里的或插班补缺试听的会员
    List<CallMemberDto> getClassMemberAndCallMember(String storeUid, Long classId, String lessonUid);

    // 获取点名时的会员uid，社团里的或插班补缺试听的会员
    List<String> getMemberUidByClassMemberAndCallMember(String storeUid, Long classId, String lessonUid);


    // 获取当天已进行活动，未完成的活动
    List<CaScheduleLesson> getTodayUseNotOk(String ymd, Long classId);

    boolean haveProjectUid(String storeUid, String projectUid);

    boolean haveStageUid(String storeUid, String stageUid);

    // 获取大于当天日期的门店未进行的活动总数
    long getNotConductedCntByToday(String corpUid, String storeUid, String today);

    List<CaScheduleLesson> listByStoreUidAndLessonUidIn(String storeUid, List<String> lessonUidList);
}
